package edu.mama.college.mapper;

import edu.mama.college.model.SmsSendRecord;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

@Mapper
@Repository("SmsSendRecordMapper")
public interface SmsSendRecordMapper {

    @Select("INSERT INTO sms_send_record (mobile,code,send_time) VALUES(#{mobile},#{code},CURRENT_TIMESTAMP)")
    public void insert(String mobile,String code);

    @Select("UPDATE sms_send_record set code = #{code} , send_time = CURRENT_TIMESTAMP where mobile = #{mobile}")
    public void update(String mobile,String code);

    @Select("SELECT * FROM sms_send_record where mobile = #{mobile} AND code = #{code} and send_time >  DATE_SUB(NOW(), INTERVAL 5 MINUTE) ")
    public SmsSendRecord getRecord(String mobile,String code);
}
